/**
 * @file   main.cpp
 * @author zhang-zh
 * @date   2020.12.20 Sunday
 * 
 * @brief  A test for interval tree.
 * 
 */

#include "IntervalTree.h"

int main(int argc, char* argv[])
{
    IntervalTree Tree;
    Tree.insert(4.1, 7.2);
    IntervalTree::Node* y = new IntervalTree::Node(2, 9);
    Tree.insert(y);
    Tree.insert(1.3, 4.5);
    Tree.insert(3.92, 5.78);
    Tree.insert(6.03, 8.02);
    Tree.insert(5.03, 7.02);

    Tree.inorder_walk();   //check whether the tree is built correctly.
    std::cout << '\n' << std::endl;  

    IntervalTree::Node* x = Tree.lookup(3.5, 3.9);  //check the function of "lookup".
    std::cout << "[" << x->low << ", " << x->high << "]\n" << std::endl;

    Tree.del(y);
    Tree.inorder_walk();
    std::cout << '\n' << std::endl;
    x = Tree.lookup(3.5, 3.9);
    std::cout << "[" << x->low << ", " << x->high << "]\n" << std::endl;    //check the function of "del".

    return 0;
}